//初始化
$(function() {
    $("#btn_add").bind("click",saveOrUpdate);
    $.ajax({
        type: 'post',
        url: '/do/ym/getdata',
        dataType: "json",
        success: function (data) {
            $("#yid").val(data.rows[0].id);
            $("#yname").val(data.rows[0].yname);
            $("#repath").attr("src","http://45.204.14.22/upload/rwm_ok.jpg");
        }
    });
});

function saveOrUpdate() {
    $.ajax({
        type: 'post',
        url: '/do/ym/edit',
        dataType: "json",
        data:{
            id:$("#yid").val(),
            yname:$("#yname").val()
        },
        success: function (data) {
            if(data.code==0){
                Ewin.alert(data.msg);
            }else{
                $("#repath").removeAttr("src");
                $("#repath").attr("src","http://45.204.14.22/upload/rwm_ok.jpg?date="+new Date());
            }
        }
    });
}

